package com.example.demo.joone;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

/**
 * @Create: IntelliJ IDEA.
 * @Author: subtlman_ljx
 * @Date: 2022/10/13/14:16
 * @Description: java程序创建神经网络
 */
public class Test {


    public static void main(String[] args) {
//        new SigmoidLayer();

        new Test().parsingsql("D:\\Desktop\\551114_XGW_114_202211161400_202211161415.txt",null);

    }

    public List<String> parsingsql(String str, String batchNo) {
        List<String> sqlList = new ArrayList();
        System.out.println("开始解析文件:" + str);
        StringBuffer parsingStr = new StringBuffer("");
        String lineTxt = null;

        try {
            File file = new File(str);
            String ecoding = "GBK";
            if (file.isFile() && file.exists()) {
                InputStreamReader reader = new InputStreamReader(new FileInputStream(file), ecoding);
                BufferedReader bufferedReader = new BufferedReader(reader);

                while((lineTxt = bufferedReader.readLine()) != null) {
                    Character c = '\u0000';
                    lineTxt = lineTxt.replace(c.toString(), "");
                    parsingStr.append(lineTxt + "\n");
                }
            }

            String[] xgwDates = parsingStr.toString().split("POName=");
            String[] var12 = xgwDates;
            int var11 = xgwDates.length;

            for(int var20 = 0; var20 < var11; ++var20) {
                String date = var12[var20];
                System.out.println("==============:" + date);
                String[] texts;
                int i;
                String[] values;
                String sql;
                if (date.contains("SGW系统业务测量")) {
                    texts = date.split("\\n");

                    for(i = 2; i < texts.length; ++i) {
                        values = texts[i].split("\\s+");
                        if (values.length > 10) {
                            sql = "insert into LTE_COLLXGW_TBL(BureauId,BureauName,C051230011,datetime,pkey,spkey,batchno) values('" + values[2] + "','" + values[3] + "','" + values[4] + "',to_date('" + values[0] + " " + values[1] + "', 'yyyy-mm-dd hh24:mi:ss'),to_char(MOD(to_number(to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'YYYY')),5) + 1)||to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'MM'),'2','" + batchNo + "')";
                            sqlList.add(sql);
                        }
                    }
                } else if (date.contains("SGW系统流量测量")) {
                    texts = date.split("\\n");

                    for(i = 2; i < texts.length; ++i) {
                        values = texts[i].split("\\s+");
                        if (values.length > 10) {
                            sql = "insert into LTE_COLLXGW_TBL(BureauId,BureauName,C051240037,C051240038,datetime,pkey,spkey,batchno)values('" + values[2] + "','" + values[3] + "','" + values[30] + "','" + values[31] + "',to_date('" + values[0] + " " + values[1] + "', 'yyyy-mm-dd hh24:mi:ss'),to_char(MOD(to_number(to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'YYYY')),5) + 1) ||to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'MM'),'2','" + batchNo + "')";
                            sqlList.add(sql);
                        }
                    }
                } else if (date.contains("PGW-RADIUS信令测量")) {
                    texts = date.split("\\n");

                    for(i = 2; i < texts.length; ++i) {
                        values = texts[i].split("\\s+");
                        if (values.length > 10) {
                            sql = "insert into LTE_COLLXGW_TBL( BureauId,BureauName,C048850011,C048850012,C048850022,datetime,pkey,spkey,batchno) values('" + values[2] + "','" + values[3] + "','" + values[4] + "','" + values[5] + "','" + values[15] + "',to_date('" + values[0] + " " + values[1] + "', 'yyyy-mm-dd hh24:mi:ss'),to_char(MOD(to_number(to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'YYYY')),5) + 1) ||to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'MM'),'2','" + batchNo + "')";
                            sqlList.add(sql);
                        }
                    }
                } else if (date.contains("PGW-RAT流量测量")) {
                    texts = date.split("\\n");

                    for(i = 2; i < texts.length; ++i) {
                        values = texts[i].split("\\s+");
                        if (values.length > 10) {
                            sql = "insert into LTE_COLLXGW_TBL( BureauId,BureauName,C049000028,C049000030,datetime,pkey,spkey,batchno) values('" + values[2] + "','" + values[3] + "','" + values[21] + "','" + values[23] + "',to_date('" + values[0] + " " + values[1] + "', 'yyyy-mm-dd hh24:mi:ss'),to_char(MOD(to_number(to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'YYYY')),5) + 1) ||to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'MM'),'2','" + batchNo + "')";
                            sqlList.add(sql);
                        }
                    }
                } else if (date.contains("PGW-会话扩展测量")) {
                    texts = date.split("\\n");

                    for(i = 2; i < texts.length; ++i) {
                        values = texts[i].split("\\s+");
                        if (values.length > 10) {
                            sql = "insert into LTE_COLLXGW_TBL( BureauId,BureauName,C04949041,C04949042,datetime,pkey,spkey,batchno) values('" + values[2] + "','" + values[3] + "','" + values[34] + "','" + values[35] + "',to_date('" + values[0] + " " + values[1] + "', 'yyyy-mm-dd hh24:mi:ss'),to_char(MOD(to_number(to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'YYYY')),5) + 1) ||to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'MM'),'2','" + batchNo + "')";
                            sqlList.add(sql);
                        }
                    }
                } else if (date.contains("PGW-PMIP流量测量")) {
                    texts = date.split("\\n");

                    for(i = 2; i < texts.length; ++i) {
                        values = texts[i].split("\\s+");
                        if (values.length > 10) {
                            sql = "insert into LTE_COLLXGW_TBL( BureauId,BureauName,C049180017,C049180018,datetime,pkey,spkey,batchno) values('" + values[2] + "','" + values[3] + "','" + values[10] + "','" + values[11] + "',to_date('" + values[0] + " " + values[1] + "', 'yyyy-mm-dd hh24:mi:ss'),to_char(MOD(to_number(to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'YYYY')),5) + 1) ||to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'MM'),'2','" + batchNo + "')";
                            sqlList.add(sql);
                        }
                    }
                } else if (date.contains("PGW-流量测量")) {
                    texts = date.split("\\n");

                    for(i = 2; i < texts.length; ++i) {
                        values = texts[i].split("\\s+");
                        if (values.length > 10) {
                            sql = "insert into LTE_COLLXGW_TBL( BureauId,BureauName,C048660084,C048660085,c048660017,c048660018,datetime,pkey,spkey,batchno) values('" + values[2] + "','" + values[3] + "','" + values[60] + "','" + values[61] + "','" + values[10] + "','" + values[11] + "',to_date('" + values[0] + " " + values[1] + "', 'yyyy-mm-dd hh24:mi:ss'),to_char(MOD(to_number(to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'YYYY')),5) + 1) ||to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'MM'),'2','" + batchNo + "')";
                            sqlList.add(sql);
                        }
                    }
                } else if (date.contains("PGW-APN GxGy流量测量")) {
                    texts = date.split("\\n");

                    for(i = 2; i < texts.length; ++i) {
                        values = texts[i].split("\\s+");
                        if (values.length > 10) {
                            sql = "insert into LTE_COLLXGW_TBL( BureauId,BureauName,C049210031,C049210034,C049210032,C049210033,C049210035,C049210036,datetime,pkey,spkey,batchno) values('" + values[2] + "','" + values[3] + "','" + values[24] + "','" + values[27] + "','" + values[25] + "','" + values[26] + "','" + values[28] + "','" + values[29] + "',to_date('" + values[0] + " " + values[1] + "', 'yyyy-mm-dd hh24:mi:ss'),to_char(MOD(to_number(to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'YYYY')),5) + 1) ||to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'MM'),'2','" + batchNo + "')";
                            sqlList.add(sql);
                        }
                    }
                } else if (date.contains("PGW-会话测量")) {
                    texts = date.split("\\n");

                    for(i = 2; i < texts.length; ++i) {
                        values = texts[i].split("\\s+");
                        if (values.length > 10) {
                            sql = "insert into LTE_COLLXGW_TBL( BureauId,BureauName,C048650125,datetime,pkey,spkey,batchno) values('" + values[2] + "','" + values[3] + "','" + values[109] + "',to_date('" + values[0] + " " + values[1] + "', 'yyyy-mm-dd hh24:mi:ss'),to_char(MOD(to_number(to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'YYYY')),5) + 1) ||to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'MM'),'2','" + batchNo + "')";
                            sqlList.add(sql);
                        }
                    }
                } else if (date.contains("PGW-DCC性能测量")) {
                    texts = date.split("\\n");

                    for(i = 2; i < texts.length; ++i) {
                        values = texts[i].split("\\s+");
                        if (values.length > 10) {
                            sql = "insert into LTE_COLLXGW_TBL( BureauId,BureauName,OBJECTID,C048760022,C048760024,C048760026,datetime,pkey,spkey,batchno) values('" + values[2] + "','" + values[3] + "','" + values[4] + "','" + values[19] + "','" + values[21] + "','" + values[23] + "',to_date('" + values[0] + " " + values[1] + "', 'yyyy-mm-dd hh24:mi:ss'),to_char(MOD(to_number(to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'YYYY')),5) + 1) ||to_char(to_date('" + values[0] + " " + values[1] + "','yyyy-mm-dd hh24:mi:ss'),'MM'),'2','" + batchNo + "')";
                            sqlList.add(sql);
                        }
                    }
                } else if (date.contains("PGW-APN会话测量")) {
                    texts = date.split("\\n");
                    Map<String, String> vals = new HashMap();

                    for(i = 2; i < texts.length; ++i) {
                        values = texts[i].split("\\s+");
                        if (values.length > 10 && values[5].contains("ctwap")) {
                            vals.put("ctwap", texts[i].split("\\s+")[100]);
                            vals.put("val0", values[0]);
                            vals.put("val1", values[1]);
                            vals.put("val2", values[2]);
                            vals.put("val3", values[3]);
                        } else if (values.length > 10 && values[5].contains("private.vpdn")) {
                            vals.put("private", values[100]);
                            vals.put("val0", values[0]);
                            vals.put("val1", values[1]);
                            vals.put("val2", values[2]);
                            vals.put("val3", values[3]);
                        } else if (values.length > 10 && values[5].contains("public.vpdn")) {
                            vals.put("public", values[100]);
                            vals.put("val0", values[0]);
                            vals.put("val1", values[1]);
                            vals.put("val2", values[2]);
                            vals.put("val3", values[3]);
                        } else if (values.length > 10 && values[5].contains("ctnet")) {
                            vals.put("ctnet", values[100]);
                            vals.put("val0", values[0]);
                            vals.put("val1", values[1]);
                            vals.put("val2", values[2]);
                            vals.put("val3", values[3]);
                        } else if (values.length > 10 && values[5].contains("ctlte")) {
                            vals.put("ctlte", values[100]);
                            vals.put("val0", values[0]);
                            vals.put("val1", values[1]);
                            vals.put("val2", values[2]);
                            vals.put("val3", values[3]);
                        } else if (values.length > 10 && values[5].contains("ims")) {
                            vals.put("ims", values[100]);
                            vals.put("val0", values[0]);
                            vals.put("val1", values[1]);
                            vals.put("val2", values[2]);
                            vals.put("val3", values[3]);
                        }
                    }

                    sql = "insert into LTE_COLLXGW_TBL( BureauId,BureauName,c048670101_ctwap,c048670101_privatevpdn,c048670101_publicvpdn,c048670101_ctnet,c048670101_ctlte,c048670101_ims,datetime,pkey,spkey,batchno) values('" + (String)vals.get("val2") + "','" + (String)vals.get("val3") + "','" + (vals.get("ctwap") != null ? (String)vals.get("ctwap") : "") + "','" + (vals.get("private") != null ? (String)vals.get("private") : "") + "','" + (vals.get("public") != null ? (String)vals.get("public") : "") + "','" + (vals.get("ctnet") != null ? (String)vals.get("ctnet") : "") + "','" + (vals.get("ctlte") != null ? (String)vals.get("ctlte") : "") + "','" + (vals.get("ims") != null ? (String)vals.get("ims") : "") + "',to_date('" + (String)vals.get("val0") + " " + (String)vals.get("val1") + "', 'yyyy-mm-dd hh24:mi:ss')," + "to_char(MOD(to_number(to_char(to_date('" + (String)vals.get("val0") + " " + (String)vals.get("val1") + "','yyyy-mm-dd hh24:mi:ss'),'YYYY')),5) + 1) ||to_char(to_date('" + (String)vals.get("val0") + " " + (String)vals.get("val1") + "','yyyy-mm-dd hh24:mi:ss'),'MM'),'2','" + batchNo + "')";
                    System.out.println("插入语句：==============" + sql);
                    sqlList.add(sql);
                }
            }
        } catch (IOException var18) {
            System.out.println("打开" + str + "TXT文件错误:" + var18.getLocalizedMessage());
        }

        return sqlList;
    }


}
